function test_GetAffine()

%%
%initialize vector grid
%[x,y] = ndgrid(0:255,0:255);
[x,y]=ndgrid(0:255,0:255);
%xd=x-(size(Imoving,1)/2); yd=y-(size(Imoving,2)/2);
%x = zeros(256,256); y = zeros(256,256);
xd=x-(256/2); yd=y-(256/2);
%xd = x; yd = y;
%%
%initialize transfrom matrix
%
ATM = make_transformation_matrix([25 33],pi/6,[1 1])

%initialize transformed vector field
%XAT = (256/2 + ATM(1,1) * x + ATM(1,2) * y + ATM(1,3) * 1);
%YAT = (256/2 + ATM(2,1) * x + ATM(2,2) * y + ATM(2,3) * 1);

XAT = ATM(1,1) * xd + ATM(1,2) * yd + ATM(1,3) * 1;
YAT = ATM(2,1) * xd + ATM(2,2) * yd + ATM(2,3) * 1;

DXAT = 128 + XAT - x;
DYAT = 128 + YAT - y;

%DXAT = XAT-x;
%DYAT = YAT-y;
%%
I = imread('images/modtest1.png');
Imoving = movepixels(I,DXAT,DYAT,[],0);
figure, imshow(Imoving,[]);
figure, imshow(I,[]);

[A, b] = GetAffineMatrix(XAT,YAT,xd,yd)

%%
%TX = A(1,1)*xd + A(1,2)*yd + b(1,1)*1 -x;
%TY = A(2,1)*xd + A(2,2)*yd + b(1,2)*1 -y;

TX = (128 + A(1,1)*xd + A(1,2)*yd + b(1,1)*1) - x;
TY = (128 + A(2,1)*xd + A(2,2)*yd + b(1,2)*1) - y;

IT = movepixels(Imoving,TX,TY,[],3);
figure, imshow(IT,[]);